package com.xyht.sca_s.student_manage_system.modules.salaryManagement.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.salaryManagement.entity.req.SmsSalaryDetailReq;
import com.xyht.sca_s.student_manage_system.modules.salaryManagement.entity.req.SmsSalaryDetailUpdateReq;
import com.xyht.sca_s.student_manage_system.modules.salaryManagement.entity.resp.SmsSalaryDetailBatchReq;
import com.xyht.sca_s.student_manage_system.modules.salaryManagement.service.SmsSalaryDetailService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 工资单详情表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-09-14
 */
@RestController
@RequestMapping("/salary/detail")
@SecretBody
public class SmsSalaryDetailController {
    @Autowired
    private SmsSalaryDetailService smsSalaryDetailService;
    @Autowired
    private JwtTokenUtil jwtTokenUtil;

    @GetMapping("/list")
    @ApiModelProperty(value = "工资单列表获取")
    public ResponseResult getSalaryDetailList(@RequestParam("search_str") String search_str,
                                              @RequestParam("task_id") String task_id,
                                              @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize
                                              ) {
        return smsSalaryDetailService.getSalaryDetailList(pageNum, pageSize, task_id, search_str);
    }
    @GetMapping("/detail")
    @ApiModelProperty(value = "工资单详情获取")
    public ResponseResult getSalaryDetailDetail(@RequestParam("detail_id") String detail_id) {
        return smsSalaryDetailService.getSalaryDetailDetail(detail_id);
    }

    @PostMapping("/update")
    @ApiModelProperty(value = "工资单修改")
    public ResponseResult updateSalaryDetail(@RequestBody SmsSalaryDetailUpdateReq req, HttpServletRequest request) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsSalaryDetailService.updateSalaryDetail(req, user_id);
    }
    @PostMapping("/batchRecall")
    @ApiModelProperty(value = "工资单批量撤回")
    public ResponseResult batchCancelSalaryDetail(@RequestBody SmsSalaryDetailBatchReq req) {
        return smsSalaryDetailService.batchCancelSalaryDetail(req);
    }
    @PostMapping("/allRecall")
    @ApiModelProperty(value = "工资单全部撤回")
    public ResponseResult allCancelSalaryDetail(@RequestBody SmsSalaryDetailBatchReq req) {
        return smsSalaryDetailService.allCancelSalaryDetail(req);
    }
    @PostMapping("/batchPublish")
    @ApiModelProperty(value = "工资单批量发布")
    public ResponseResult batchPublishSalaryDetail(@RequestBody SmsSalaryDetailBatchReq req,HttpServletRequest request) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsSalaryDetailService.batchPublishSalaryDetail(req,user_id);
    }
    @PostMapping("/allPublish")
    @ApiModelProperty(value = "工资单全部发布")
    public ResponseResult allPublishSalaryDetail(@RequestBody SmsSalaryDetailBatchReq req,HttpServletRequest request) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsSalaryDetailService.allPublishSalaryDetail(req,user_id);
    }
    @PostMapping("/deleted")
    @ApiModelProperty(value = "工资单删除")
    public ResponseResult deleteSalaryDetail(@RequestBody SmsSalaryDetailReq req) {
        return smsSalaryDetailService.deleteSalaryDetail(req);
    }

    @GetMapping("/userList")
    @ApiModelProperty(value = "用户工资单列表获取")
    public ResponseResult userGetSalaryDetailList(HttpServletRequest request) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsSalaryDetailService.userGetSalaryDetailList(user_id);
    }

    @GetMapping("/userDetail")
    @ApiModelProperty(value = "用户工资单详情获取")
    public ResponseResult userGetSalaryDetailDetail(@RequestParam("detail_id") String detail_id) {
        return smsSalaryDetailService.userGetSalaryDetailDetail(detail_id);
    }

}

